//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#include <buola/io/cfileimpl.h>

#include <buola/io/cfile.h>

namespace buola { namespace io {

///returns a vector with the names of all children
std::vector<std::string> CFileImpl::GetChildrenNames(PFileFilter pFilter)
{
    std::vector<CFile> lFiles=GetChildren(pFilter);
    std::vector<std::string> lResult;
    
    lResult.reserve(lFiles.size());
    
    for(int i=0;i<lFiles.size();i++)
        lResult.push_back(lFiles[i].URI().Name());
        
    return lResult;
}

///returns a set with the names of all children
std::unordered_set<std::string> CFileImpl::GetChildrenSet(PFileFilter pFilter)
{
    std::vector<CFile> lFiles=GetChildren(pFilter);
    std::unordered_set<std::string> lResult;
    
    for(int i=0;i<lFiles.size();i++)
        lResult.insert(lFiles[i].URI().Name());
        
    return lResult;
}

///returns a vector with the names of all children
std::vector<io::CURI> CFileImpl::GetChildrenURIs(PFileFilter pFilter)
{
    std::vector<CFile> lFiles=GetChildren(pFilter);
    std::vector<io::CURI> lResult;
    
    lResult.reserve(lFiles.size());
    
    for(int i=0;i<lFiles.size();i++)
        lResult.push_back(lFiles[i].URI());
        
    return lResult;
}

///returns true if the folder has any children matching the filter
bool CFileImpl::HasChildren(PFileFilter pFilter)
{
    return !GetChildren(pFilter).empty();
}


/*namespace io*/ } /*namespace buola*/ }
